

USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[BacSi]    Script Date: 09/01/2011 23:19:24 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BacSi](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
	[GioiTinh] [int] NULL,
	[NgaySinh] [datetime] NULL,
	[DiaChi] [nvarchar](100) NULL,
	[DienThoai] [nchar](50) NULL,
	[MucCoDong] [float] NULL,
 CONSTRAINT [PK_BacSi] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[Phieu]    Script Date: 09/01/2011 23:19:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Phieu](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ngay] [datetime] NULL,
	[NguoiThucHien] [nvarchar](50) NULL,
	[DiaChi] [nvarchar](100) NULL,
	[DienThoai] [nchar](50) NULL,
	[NoiDung] [nvarchar](100) NULL,
	[SoTien] [float] NULL,
	[Loai] [int] NULL,
 CONSTRAINT [PK_Phieu] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[DanhMucBenhTienSu]    Script Date: 09/01/2011 23:19:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DanhMucBenhTienSu](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
 CONSTRAINT [PK_DanhMucBenhTienSu] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[DanhMucDichVu]    Script Date: 09/01/2011 23:20:05 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DanhMucDichVu](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
	[Gia] [float] NULL,
	[CoSuDung] [int] NULL,
 CONSTRAINT [PK_DanhMucBenh] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[DanhMucLoaiBenhNhan]    Script Date: 09/01/2011 23:20:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DanhMucLoaiBenhNhan](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
 CONSTRAINT [PK_LoaiBenhNhan] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[DanhMucNgheNghiep]    Script Date: 09/01/2011 23:20:20 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DanhMucNgheNghiep](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
 CONSTRAINT [PK_NgheNghiep] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[Quan]    Script Date: 09/01/2011 17:55:47 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Quan](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[Ten] [nvarchar](50) NULL,
 CONSTRAINT [PK_Quan] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[BenhNhan]    Script Date: 09/01/2011 23:20:48 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BenhNhan](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[HoTen] [nvarchar](50) NULL,
	[GioiTinh] [int] NULL,
	[NgaySinh] [datetime] NULL,
	[DiaChi] [nvarchar](100) NULL,
	[MaQuan] [int] NULL,
	[DienThoai] [nchar](50) NULL,
	[MaNgheNghiep] [int] NULL,
	[MaLoai] [int] NULL,
	[KhamDinhKi] [int] NULL,
	[HinhAnh] [nvarchar](50) NULL,
	[TongChiPhi] [float] NULL,
	[TienConNo] [float] NULL,
 CONSTRAINT [PK_BenhNhan] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BenhNhan]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan_DanhMucLoaiBenhNhan] FOREIGN KEY([MaLoai])
REFERENCES [dbo].[DanhMucLoaiBenhNhan] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan] CHECK CONSTRAINT [FK_BenhNhan_DanhMucLoaiBenhNhan]
GO

ALTER TABLE [dbo].[BenhNhan]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan_DanhMucNgheNghiep] FOREIGN KEY([MaNgheNghiep])
REFERENCES [dbo].[DanhMucNgheNghiep] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan] CHECK CONSTRAINT [FK_BenhNhan_DanhMucNgheNghiep]
GO

ALTER TABLE [dbo].[BenhNhan]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan_Quan] FOREIGN KEY([MaQuan])
REFERENCES [dbo].[Quan] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan] CHECK CONSTRAINT [FK_BenhNhan_Quan]
GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[BenhNhan-BenhTienSu]    Script Date: 09/01/2011 23:21:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BenhNhan-BenhTienSu](
	[MaBenhNhan] [int] NOT NULL,
	[MaBenhTienSu] [int] NOT NULL,
	[GhiChu] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_BenhNhan-BenhTienSu] PRIMARY KEY CLUSTERED 
(
	[MaBenhNhan] ASC,
	[MaBenhTienSu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BenhNhan-BenhTienSu]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan-BenhTienSu_BenhNhan] FOREIGN KEY([MaBenhNhan])
REFERENCES [dbo].[BenhNhan] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan-BenhTienSu] CHECK CONSTRAINT [FK_BenhNhan-BenhTienSu_BenhNhan]
GO

ALTER TABLE [dbo].[BenhNhan-BenhTienSu]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan-BenhTienSu_DanhMucBenhTienSu] FOREIGN KEY([MaBenhTienSu])
REFERENCES [dbo].[DanhMucBenhTienSu] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan-BenhTienSu] CHECK CONSTRAINT [FK_BenhNhan-BenhTienSu_DanhMucBenhTienSu]
GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[BenhNhan-Phieu]    Script Date: 09/01/2011 23:21:15 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BenhNhan-Phieu](
	[MaBenhNhan] [int] NOT NULL,
	[MaPhieu] [int] NOT NULL,
	[GhiChu] [nvarchar](50) NULL,
 CONSTRAINT [PK_BenhNhan-Phieu] PRIMARY KEY CLUSTERED 
(
	[MaBenhNhan] ASC,
	[MaPhieu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BenhNhan-Phieu]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan-Phieu_BenhNhan] FOREIGN KEY([MaBenhNhan])
REFERENCES [dbo].[BenhNhan] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan-Phieu] CHECK CONSTRAINT [FK_BenhNhan-Phieu_BenhNhan]
GO

ALTER TABLE [dbo].[BenhNhan-Phieu]  WITH CHECK ADD  CONSTRAINT [FK_BenhNhan-Phieu_Phieu] FOREIGN KEY([MaPhieu])
REFERENCES [dbo].[Phieu] ([Ma])
GO

ALTER TABLE [dbo].[BenhNhan-Phieu] CHECK CONSTRAINT [FK_BenhNhan-Phieu_Phieu]
GO


USE [DentalSoftware]
GO

/****** Object:  Table [dbo].[DotDieuTri]    Script Date: 09/11/2011 12:40:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DotDieuTri](
	[Ma] [int] IDENTITY(1,1) NOT NULL,
	[MaBenhNhan] [int] NULL,
	[NgayKham] [datetime] NULL,
	[MaBacSi] [int] NULL,
	[LyDoKham] [nvarchar](max) NULL,
	[ChanDoan] [nvarchar](max) NULL,
	[Rang] [nchar](10) NULL,
	[CongViec] [nvarchar](max) NULL,
	[ChiPhi] [float] NULL,
	[DuaTruoc] [float] NULL,
	[ConLai] [float] NULL,
	[GhiChu] [nvarchar](max) NULL,
 CONSTRAINT [PK_DotDieuTri] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[DotDieuTri]  WITH CHECK ADD  CONSTRAINT [FK_DotDieuTri_BacSi] FOREIGN KEY([MaBacSi])
REFERENCES [dbo].[BacSi] ([Ma])
GO

ALTER TABLE [dbo].[DotDieuTri] CHECK CONSTRAINT [FK_DotDieuTri_BacSi]
GO

ALTER TABLE [dbo].[DotDieuTri]  WITH CHECK ADD  CONSTRAINT [FK_DotDieuTri_BenhNhan] FOREIGN KEY([MaBenhNhan])
REFERENCES [dbo].[BenhNhan] ([Ma])
GO

ALTER TABLE [dbo].[DotDieuTri] CHECK CONSTRAINT [FK_DotDieuTri_BenhNhan]
GO





USE [DentalSoftware]
GO

/****** Object:  Table [dbo].[ChiTietDieuTri]    Script Date: 09/01/2011 09:58:35 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ChiTietDieuTri](
	[Ma] [int] NOT NULL,
	[MaDotDieuTri] [int] NOT NULL,
	[MaDichVu] [int] NULL,
	[Ngay] [datetime] NULL,
	[Rang] [nchar](10) NULL,
	[CongViecDieuTri] [nvarchar](max) NULL,
	[GhiChu] [nvarchar](max) NULL,
 CONSTRAINT [PK_ChiTietDieuTri] PRIMARY KEY CLUSTERED 
(
	[Ma] ASC,
	[MaDotDieuTri] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[ChiTietDieuTri]  WITH CHECK ADD  CONSTRAINT [FK_ChiTietDieuTri_DanhMucDichVu] FOREIGN KEY([MaDichVu])
REFERENCES [dbo].[DanhMucDichVu] ([Ma])
GO

ALTER TABLE [dbo].[ChiTietDieuTri] CHECK CONSTRAINT [FK_ChiTietDieuTri_DanhMucDichVu]
GO

ALTER TABLE [dbo].[ChiTietDieuTri]  WITH CHECK ADD  CONSTRAINT [FK_ChiTietDieuTri_DotDieuTri] FOREIGN KEY([MaDotDieuTri])
REFERENCES [dbo].[DotDieuTri] ([Ma])
GO

ALTER TABLE [dbo].[ChiTietDieuTri] CHECK CONSTRAINT [FK_ChiTietDieuTri_DotDieuTri]
GO


USE [DENTALSOFTWARE]
GO

/****** Object:  Table [dbo].[DotDieuTri-DichVu]    Script Date: 09/01/2011 23:23:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DotDieuTri-DichVu](
	[MaDotDieuTri] [int] NOT NULL,
	[MaDichVu] [int] NOT NULL,
	[ThucHien] [int] NULL,
	[MaTrangThai] [int] NULL,
 CONSTRAINT [PK_DotDieuTri-DichVu] PRIMARY KEY CLUSTERED 
(
	[MaDotDieuTri] ASC,
	[MaDichVu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[DotDieuTri-DichVu]  WITH CHECK ADD  CONSTRAINT [FK_DotDieuTri-DichVu_DanhMucDichVu] FOREIGN KEY([MaDichVu])
REFERENCES [dbo].[DanhMucDichVu] ([Ma])
GO

ALTER TABLE [dbo].[DotDieuTri-DichVu] CHECK CONSTRAINT [FK_DotDieuTri-DichVu_DanhMucDichVu]
GO

ALTER TABLE [dbo].[DotDieuTri-DichVu]  WITH CHECK ADD  CONSTRAINT [FK_DotDieuTri-DichVu_DotDieuTri] FOREIGN KEY([MaDotDieuTri])
REFERENCES [dbo].[DotDieuTri] ([Ma])
GO

ALTER TABLE [dbo].[DotDieuTri-DichVu] CHECK CONSTRAINT [FK_DotDieuTri-DichVu_DotDieuTri]
GO


